varying float alpha;
uniform float alphamultiplier;

uniform vec3 camPos;
uniform vec4 camproj1;
uniform vec4 camproj2;
uniform vec4 camproj3;
uniform vec4 camproj4;

void main()
{
   vec4 ecPosition  = gl_ModelViewMatrix * gl_Vertex;
   vec3 ecPosition3 = ecPosition.xyz / ecPosition.w;
   mat4 worldMatrix = mat4(camproj1, camproj2, camproj3, camproj4);
   vec4 ecCamPos = worldMatrix * vec4(camPos, 1.0);
   vec3 ecCamPos3 = ecCamPos.xyz / ecCamPos.w;
   float i = 1.0-min(1.0, length(ecPosition3 - ecCamPos3)/100.0);
   alpha = (alphamultiplier + 4*i) * gl_Normal[0];
   gl_FrontColor = gl_Color;//
   gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}
